<?php

/**
 * ftAdvertise admin form
 *
 * @package    fantaseagroup
 * @subpackage ftAdvertise
 * @author     Your name here
 */
class FtAdvertiseAdminForm extends BaseFtAdvertiseForm
{
  public function configure()
  {
    parent::configure();
        $this->validatorSchema['name'] = new sfValidatorString(
      array(
        'required' => true, 'max_length' => 255, 'trim'=>true),
      array(
        'invalid' => 'Tên không hợp lệ',
      	'max_length' => 'Tên dài quá 255 kí tự',
        'required'=> 'Chưa nhập tên'
      ));

    $this->validatorSchema['link'] = new sfValidatorUrl(
            array('required' => false, 'max_length' => 255, 'trim'=>true),
            array(
                'invalid' => 'Liên kết không đúng định dạng',
                'max_length' => 'Liên kết dài quá 255 kí tự',

            ));
    $this->validatorSchema['location_id'] = new sfValidatorString(
            array('required' => false, 'max_length' => 255, 'trim'=>true),
            array(
              'max_length' => 'Quá dài',
              'required'=> 'Bắt buộc'
                ));
  }
  public function createMediaFormForImageId()
  {
    $required = true;
    $form = DmMediaForRecordForm::factory($this->object, 'image_id', 'DmMedia', $required);

    // choose mime types allowed
    $form->setMimeTypeWhiteList(array(
      'image/jpeg',
      'image/png',
      'image/gif',
      'application/x-shockwave-flash'
    ));
    $form->validatorSchema['file']->setOption('max_size', 5000000);
    $form->validatorSchema['file']->setMessage('max_size',('File lớn quá 5Mb'));
    $form->validatorSchema['file']->setMessage('required',('Chưa nhập File'));
    unset($form['legend'], $form['author'], $form['license']);
    $this->validatorSchema['target'] = new sfValidatorUrl(array('max_length' => 255, 'required' => false));
    $form->getWidgetSchema()->getFormFormatter()->setErrorListFormatInARow('');
    return $form;
  }
}